<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>

<body>
    <div id="app">

        <!-- 重新渲染，input框的内容不变，所以需要增加key值 -->
        <div v-if="show">
            用户名：<input type="text" :key="username">
        </div>
        <div v-else>
            密码：<input type="text" :key="password">
        </div>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                show: false,
            }

        })
    </script>
</body>

</html>